/**
 * 
 * 起迪科技 Copyright (c) 2014-2018 QiDi,Inc.All Rights Reserved.
 */
package cn.qidisoft.edu.hzjt.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.qidisoft.core.common.code.QdfRespCode;
import cn.qidisoft.core.common.exception.dao.DBException;
import cn.qidisoft.core.common.log.LoggerAdapter;
import cn.qidisoft.core.common.log.LoggerAdapterFactory;
import cn.qidisoft.edu.hzjt.dao.SysLogMapper;
import cn.qidisoft.edu.hzjt.model.SysLog;
import cn.qidisoft.edu.hzjt.service.ILoggerService;
import cn.qidisoft.edu.hzjt.utils.LogType;


/**
 * 
 * @author hxq
 * @version $Id: LoggerServiceImpl.java, v 0.1 2018年9月18日 下午5:55:55 hxq Exp $
 */
@Service("loggerService")
public class LoggerServiceImpl implements ILoggerService {
  protected static final LoggerAdapter LOGGER =
      LoggerAdapterFactory.getLogger(LogType.HZJT_LOGGER.val);
  @Autowired
  private SysLogMapper sysLogMapper;

  /**
   * @see cn.qidisoft.edu.hzjt.service.ILoggerService#addLogger(cn.qidisoft.edu.hzjt.model.SysLog)
   */
  @Override
  public void addLogger(SysLog logger) {
    try {
      sysLogMapper.insert(logger);
    } catch (DBException e) {
      LOGGER.error(e.getMessage(), e);
      throw new DBException(QdfRespCode.QDF_020004.getCode(), QdfRespCode.QDF_020004.getMsg(), e);
    }

  }

  /**
   * @see cn.qidisoft.edu.hzjt.service.ILoggerService#updateLogger(cn.qidisoft.edu.hzjt.model.SysLog)
   */
  @Override
  public void updateLogger(SysLog logger) {
    try {
      sysLogMapper.updateByPK(logger);
    } catch (DBException e) {
      LOGGER.error(e.getMessage(), e);
      throw new DBException(QdfRespCode.QDF_020004.getCode(), QdfRespCode.QDF_020004.getMsg(), e);
    }

  }

}
